<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>C MIP-SDK: mip.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">C MIP-SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">mip.h</div>  </div>
</div>
<div class="contents">
<a href="mip_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment"></span><span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment"></span><span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// External dependencies:</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">//  mip_types.h</span>
<a name="l00012"></a>00012 <span class="comment">// </span>
<a name="l00014"></a>00014 <span class="comment"></span><span class="comment">//</span>
<a name="l00017"></a>00017 <span class="comment"></span><span class="comment">//</span>
<a name="l00027"></a>00027 <span class="comment"></span><span class="comment">//</span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#ifndef _MIP_H</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define _MIP_H</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span> <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00036"></a>00036 <span class="preprocessor">#endif</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>   
<a name="l00039"></a>00039 <span class="comment">//</span>
<a name="l00040"></a>00040 <span class="comment">//Include Files</span>
<a name="l00041"></a>00041 <span class="comment">//</span>
<a name="l00043"></a>00043 <span class="comment"></span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &quot;<a class="code" href="mip__types_8h.html">mip_types.h</a>&quot;</span>
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 
<a name="l00048"></a>00048 <span class="comment">//</span>
<a name="l00049"></a>00049 <span class="comment">// Defines</span>
<a name="l00050"></a>00050 <span class="comment">//</span>
<a name="l00052"></a>00052 <span class="comment"></span>
<a name="l00053"></a>00053 
<a name="l00055"></a>00055 <span class="comment">// MIP </span>
<a name="l00057"></a>00057 <span class="comment"></span>
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 <span class="comment">//Sync Bytes</span>
<a name="l00061"></a>00061 <span class="preprocessor">#define MIP_SYNC_BYTE1         0x75 </span>
<a name="l00062"></a>00062 <span class="preprocessor"></span><span class="preprocessor">#define MIP_SYNC_BYTE2         0x65</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span>
<a name="l00064"></a>00064 <span class="comment">//MIP Packet Sizes</span>
<a name="l00065"></a>00065 <span class="preprocessor">#define MIP_HEADER_SIZE           sizeof(mip_header)            </span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#define MIP_CHECKSUM_SIZE         2</span>
<a name="l00067"></a>00067 <span class="preprocessor"></span><span class="preprocessor">#define MIP_MAX_PAYLOAD_SIZE      255</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span><span class="preprocessor">#define MIP_MAX_PAYLOAD_DATA_SIZE 253</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#define MIP_FIELD_HEADER_SIZE     sizeof(mip_field_header)</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span><span class="preprocessor">#define MIP_MAX_PACKET_SIZE       (MIP_HEADER_SIZE + MIP_MAX_PAYLOAD_SIZE + MIP_CHECKSUM_SIZE)</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span>
<a name="l00072"></a>00072 
<a name="l00074"></a>00074 <span class="comment">// GLOBAL MIP DESCRIPTORS  (global desc are 0xF0 - 0xFF) - same usage in all descriptor sets</span>
<a name="l00076"></a>00076 <span class="comment"></span>
<a name="l00077"></a>00077 <span class="preprocessor">#define MIP_REPLY_DESC_GLOBAL_ACK_NACK                                  0xF1 // Ack/nack desc is same in all sets</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span><span class="preprocessor">#define MIP_DESC_GLOBAL_PRODUCTION_TEST                                 0xFE // Production Test desc is same in all sets</span>
<a name="l00079"></a>00079 <span class="preprocessor"></span>
<a name="l00080"></a>00080 
<a name="l00082"></a>00082 <span class="comment">// GLOBAL ACK/NACK ERROR CODES</span>
<a name="l00084"></a>00084 <span class="comment"></span>
<a name="l00085"></a>00085 <span class="preprocessor">#define MIP_ACK_NACK_ERROR_NONE                0x00</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00087"></a>00087 <span class="preprocessor">#define MIP_ACK_NACK_ERROR_UNKNOWN_COMMAND        0x01</span>
<a name="l00088"></a>00088 <span class="preprocessor"></span><span class="preprocessor">#define MIP_ACK_NACK_ERROR_CHECKSUM_INVALID       0x02</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span><span class="preprocessor">#define MIP_ACK_NACK_ERROR_PARAMETER_INVALID      0x03</span>
<a name="l00090"></a>00090 <span class="preprocessor"></span><span class="preprocessor">#define MIP_ACK_NACK_ERROR_COMMAND_FAILED         0x04</span>
<a name="l00091"></a>00091 <span class="preprocessor"></span><span class="preprocessor">#define MIP_ACK_NACK_ERROR_COMMAND_TIMEOUT        0x05</span>
<a name="l00092"></a>00092 <span class="preprocessor"></span><span class="preprocessor">#define MIP_ACK_NACK_ERROR_UNKNOWN_DESCRIPTOR_SET 0x06</span>
<a name="l00093"></a>00093 <span class="preprocessor"></span>
<a name="l00094"></a>00094 
<a name="l00095"></a>00095 
<a name="l00097"></a>00097 <span class="comment">//Function Return Codes</span>
<a name="l00099"></a>00099 <span class="comment"></span>
<a name="l00100"></a>00100 <span class="preprocessor">#define MIP_OK                   0</span>
<a name="l00101"></a>00101 <span class="preprocessor"></span><span class="preprocessor">#define MIP_ERROR                1</span>
<a name="l00102"></a>00102 <span class="preprocessor"></span><span class="preprocessor">#define MIP_MEMORY_ERROR         2</span>
<a name="l00103"></a>00103 <span class="preprocessor"></span><span class="preprocessor">#define MIP_FIELD_NOT_AVAILABLE  3</span>
<a name="l00104"></a>00104 <span class="preprocessor"></span><span class="preprocessor">#define MIP_INVALID_PACKET       4</span>
<a name="l00105"></a>00105 <span class="preprocessor"></span><span class="preprocessor">#define MIP_CHECKSUM_ERROR       5</span>
<a name="l00106"></a>00106 <span class="preprocessor"></span>
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="comment">//Function Selector Byte for Settings </span>
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 <span class="preprocessor">#define MIP_FUNCTION_SELECTOR_WRITE        0x01</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span><span class="preprocessor">#define MIP_FUNCTION_SELECTOR_READ         0x02</span>
<a name="l00112"></a>00112 <span class="preprocessor"></span><span class="preprocessor">#define MIP_FUNCTION_SELECTOR_STORE_EEPROM 0x03</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span><span class="preprocessor">#define MIP_FUNCTION_SELECTOR_LOAD_EEPROM  0x04</span>
<a name="l00114"></a>00114 <span class="preprocessor"></span><span class="preprocessor">#define MIP_FUNCTION_SELECTOR_LOAD_DEFAULT 0x05</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span>
<a name="l00116"></a>00116 <span class="comment">//AHRS Supported Descriptors Macro</span>
<a name="l00117"></a>00117 <span class="preprocessor">#define IS_MIP_FUNCTION_SELECTOR(SELECTOR) (((SELECTOR) == MIP_FUNCTION_SELECTOR_WRITE)        || \</span>
<a name="l00118"></a>00118 <span class="preprocessor">                                            ((SELECTOR) == MIP_FUNCTION_SELECTOR_READ)         || \</span>
<a name="l00119"></a>00119 <span class="preprocessor">                                            ((SELECTOR) == MIP_FUNCTION_SELECTOR_STORE_EEPROM) || \</span>
<a name="l00120"></a>00120 <span class="preprocessor">                                            ((SELECTOR) == MIP_FUNCTION_SELECTOR_LOAD_EEPROM)  || \</span>
<a name="l00121"></a>00121 <span class="preprocessor">                                            ((SELECTOR) == MIP_FUNCTION_SELECTOR_LOAD_DEFAULT))</span>
<a name="l00122"></a>00122 <span class="preprocessor"></span>
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 
<a name="l00126"></a>00126 <span class="comment">//</span>
<a name="l00127"></a>00127 <span class="comment">// Structures</span>
<a name="l00128"></a>00128 <span class="comment">//</span>
<a name="l00130"></a>00130 <span class="comment"></span>
<a name="l00131"></a>00131 <span class="preprocessor">#pragma pack(1)</span>
<a name="l00132"></a>00132 <span class="preprocessor"></span>
<a name="l00134"></a>00134 <span class="comment">//MIP Packet Header </span>
<a name="l00136"></a>00136 <span class="comment"></span>
<a name="l00137"></a><a class="code" href="struct__mip__header.html">00137</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__mip__header.html">_mip_header</a>
<a name="l00138"></a>00138 {
<a name="l00139"></a>00139  u8 sync1, sync2;
<a name="l00140"></a>00140  u8 descriptor_set, payload_size; 
<a name="l00141"></a>00141 }<a class="code" href="struct__mip__header.html">mip_header</a>;
<a name="l00142"></a>00142 
<a name="l00144"></a>00144 <span class="comment">//MIP Field Header</span>
<a name="l00146"></a>00146 <span class="comment"></span>
<a name="l00147"></a><a class="code" href="struct__mip__field__header.html">00147</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__mip__field__header.html">_mip_field_header</a>
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149  u8 size;
<a name="l00150"></a>00150  u8 descriptor;
<a name="l00151"></a>00151 }<a class="code" href="struct__mip__field__header.html">mip_field_header</a>;
<a name="l00152"></a>00152 
<a name="l00153"></a>00153 
<a name="l00155"></a>00155 <span class="comment">//MIP ACK/NACK Response</span>
<a name="l00157"></a>00157 <span class="comment"></span>
<a name="l00158"></a><a class="code" href="struct__global__ack__nack__field.html">00158</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__global__ack__nack__field.html">_global_ack_nack_field</a>
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160  u8 command_echo_byte;
<a name="l00161"></a>00161  u8 error_code;
<a name="l00162"></a>00162 }<a class="code" href="struct__global__ack__nack__field.html">global_ack_nack_field</a>;
<a name="l00163"></a>00163 
<a name="l00164"></a>00164 
<a name="l00165"></a>00165 <span class="preprocessor">#pragma pack()</span>
<a name="l00166"></a>00166 <span class="preprocessor"></span>
<a name="l00167"></a>00167 
<a name="l00168"></a>00168 
<a name="l00170"></a>00170 <span class="comment">//</span>
<a name="l00171"></a>00171 <span class="comment">// Function Prototypes</span>
<a name="l00172"></a>00172 <span class="comment">//</span>
<a name="l00174"></a>00174 <span class="comment"></span>
<a name="l00175"></a>00175 u16 <a class="code" href="mip_8h.html#a39c9159abefed6cefdebf167ec2b426a">mip_init</a>(u8 *mip_buffer, u16 buffer_size, u8 descriptor_set);
<a name="l00176"></a>00176 u16 <a class="code" href="mip_8h.html#ab6af2990e4f14a36b3210490d4dc0279">mip_add_field</a>(u8 *mip_buffer, u16 buffer_size, <span class="keywordtype">void</span> *field_data, u16 data_size, u16 data_descriptor);
<a name="l00177"></a>00177 u16 <a class="code" href="mip_8h.html#aa5f586b255fb0f64c58aa9876e998203">mip_add_formatted_field</a>(u8 *mip_buffer, u16 buffer_size, <span class="keywordtype">void</span> *field);
<a name="l00178"></a>00178 u16 <a class="code" href="mip_8h.html#a4de18b339d9cc11650deb27c62d080ed">mip_finalize</a>(u8 *mip_buffer);
<a name="l00179"></a>00179 
<a name="l00180"></a>00180 u16 <a class="code" href="mip_8h.html#a94c9e41908a93a17985732862efe7221">mip_is_initialized</a>(u8 *mip_buffer, u8 descriptor_set);
<a name="l00181"></a>00181 u16 <a class="code" href="mip_8h.html#a6a52f4d47ddeb106a137e35c50d161c4">mip_is_mip_packet</a> (u8 *mip_buffer);
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 u8  <a class="code" href="mip_8h.html#ac914a614fb6032f829bc5652cff73dd9">mip_get_packet_descriptor_set</a>(u8 *mip_buffer);
<a name="l00184"></a>00184 u8  <a class="code" href="mip_8h.html#a002fe05192a78b81647c94c1581f388f">mip_get_payload_size</a>(u8 *mip_buffer);
<a name="l00185"></a>00185 u8  *<a class="code" href="mip_8h.html#aca1b26196bcbfdc8e2645fde7a8ffefc">mip_get_payload_ptr</a>(u8 *mip_buffer);
<a name="l00186"></a>00186 
<a name="l00187"></a>00187 u16 <a class="code" href="mip_8h.html#a7ba55d41fda2df7bb6ca437c7d46d9bf">mip_get_packet_size</a>(u8 *mip_buffer);
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 u16 <a class="code" href="mip_8h.html#a47b460bcec9fa9d05c797582aa41f91e">mip_get_first_field</a>(u8 *mip_buffer, <a class="code" href="struct__mip__field__header.html">mip_field_header</a> **field_header, u8 **field_data, u16 *field_offset);
<a name="l00190"></a>00190 u16 <a class="code" href="mip_8h.html#a0391cad812bc7d6d68cd0fd565a01942">mip_get_next_field</a>(u8 *mip_buffer, <a class="code" href="struct__mip__field__header.html">mip_field_header</a> **field_header, u8 **field_data, u16 *field_offset);
<a name="l00191"></a>00191 
<a name="l00192"></a>00192 u16 <a class="code" href="mip_8h.html#a65038bab666dc3aab060e6ca3ad2ba00">mip_calculate_checksum</a>(u8 *mip_buffer);
<a name="l00193"></a>00193 u16 <a class="code" href="mip_8h.html#a861285e29cf3ea99245931955d638892">mip_is_checksum_valid</a>(u8 *mip_buffer);
<a name="l00194"></a>00194 
<a name="l00195"></a>00195 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00196"></a>00196 <span class="preprocessor"></span>}
<a name="l00197"></a>00197 <span class="preprocessor">#endif</span>
<a name="l00198"></a>00198 <span class="preprocessor"></span>
<a name="l00199"></a>00199 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Fri May 30 2014 17:03:33 for C MIP-SDK by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
